﻿IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'PRC_TB_PROFILERS_FUNCTIONALITIES_SE')
	BEGIN
		DROP  Procedure  dbo.PRC_TB_PROFILERS_FUNCTIONALITIES_SE
	END

GO

CREATE Procedure dbo.PRC_TB_PROFILERS_FUNCTIONALITIES_SE
	(
		@TP_ID int = null
	)

AS

select
	distinct
	tf_id,
	tf_description
from TB_FUNCTIONALITIES
	left join TB_PROFILERS_FUNCTIONALITIES
		on tpf_functionality_id = tf_id
where @TP_ID is null or tpf_profiler_id = @TP_ID
order by tf_description

GO

GRANT EXEC ON dbo.PRC_TB_PROFILERS_FUNCTIONALITIES_SE TO PUBLIC

GO

